473,418 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Opening a dbf file with .NET code

I have a simple dbf file with the name of OTHWAGE.dbf. I can open it in
Visual Studio Server Explorer and see its fields and records by creating a
Data Connection. When I copy the connection string and combine it with code
from VS Help, I end up with the following:

Dim sConnection As String = "Provider=MSDASQL.1;
Persist Security Info=False;
Data Source=dBASE Files;
Extended Properties=""DSN=dBASE Files;DBQ=C:\Temp;
DefaultDir=c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;
DriverId=533;MaxBufferSize=2048;
PageTimeout=5
;"";
Initial Catalog=C:\Temp"

Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New System.Data.Odbc.OdbcConnection(sConnection)
Dim myCommand As New System.Data.Odbc.OdbcCommand(mySelectQuery,
myConnection)
myConnection.Open()
Dim myReader As
System.Data.Odbc.OdbcDataReader = myCommand.ExecuteReader()
While myReader.Read()
Console.WriteLine(myReader.GetString(1))
End While

For readability purposes, I added carriage returns to the connection string.
When I execute this code, I get a system error at the myConnection.Open()
line. What I am I doing wrong with this simple code?
Nov 21 '05 #1
4 14340
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider, available
from http://msdn.microsoft.com/vfoxpro/downloads/updates . For your
connection string use:

"Provider=VFPOLEDB.1;Data Source = C:\Temp;"

That's all you need for free tables. If you still have problems, post back.

--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
ci**************@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"genojoe" <ge*****@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
I have a simple dbf file with the name of OTHWAGE.dbf. I can open it in
Visual Studio Server Explorer and see its fields and records by creating a
Data Connection. When I copy the connection string and combine it with
code
from VS Help, I end up with the following:

Dim sConnection As String = "Provider=MSDASQL.1;
Persist Security Info=False;
Data Source=dBASE Files;
Extended Properties=""DSN=dBASE Files;DBQ=C:\Temp;
DefaultDir=c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;
DriverId=533;MaxBufferSize=2048;
PageTimeout=5
;"";
Initial Catalog=C:\Temp"

Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New
System.Data.Odbc.OdbcConnection(sConnection)
Dim myCommand As New System.Data.Odbc.OdbcCommand(mySelectQuery,
myConnection)
myConnection.Open()
Dim myReader As
System.Data.Odbc.OdbcDataReader = myCommand.ExecuteReader()
While myReader.Read()
Console.WriteLine(myReader.GetString(1))
End While

For readability purposes, I added carriage returns to the connection
string.
When I execute this code, I get a system error at the myConnection.Open()
line. What I am I doing wrong with this simple code?

Nov 21 '05 #2
I agree it should work. This time I even began a new project (on same
computer). One form, one button. FoxPro provider worked great in the Server
Explorer.

I crash at last line of code shown below:

Dim sConnection As String = "Provider=VFPOLEDB.1;Data Source = C:\Temp;"
Dim mySelectQuery As String = "SELECT OTHWAGE.* FROM OTHWAGE"
Dim myConnection As New System.Data.Odbc.OdbcConnection(sConnection)
Dim myCommand As New System.Data.Odbc.OdbcCommand(mySelectQuery, myConnection)

myConnection.Open()

Error message is:
An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in
system.data.dll

Additional information: System error.

Thank you for the response. Any more thoughts?
==================

"Cindy Winegarden" wrote:
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider, available
from http://msdn.microsoft.com/vfoxpro/downloads/updates . For your
connection string use:

"Provider=VFPOLEDB.1;Data Source = C:\Temp;"

That's all you need for free tables. If you still have problems, post back.

--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
ci**************@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden

Nov 21 '05 #3
I got the following to work:

Dim myConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=C:\TEMP;Extended Properties=dBase III")
Dim myCommand As New System.Data.OleDb.OleDbCommand("SELECT
OTHWAGE.* FROM OTHWAGE", myConnection)
myConnection.Open()
Dim myReader As System.Data.OleDb.OleDbDataReader =
myCommand.ExecuteReader()
While myReader.Read()
Debug.WriteLine(CStr(myReader.GetValue(0)))
End While
"Cindy Winegarden" wrote:
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider, available


Nov 21 '05 #4
Hi Joe,

I'm glad you found a work-around.

--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
ci**************@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"genojoe" <ge*****@discussions.microsoft.com> wrote in message
news:ED**********************************@microsof t.com...
I got the following to work:

Dim myConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;Data
Source=C:\TEMP;Extended Properties=dBase III")
Dim myCommand As New System.Data.OleDb.OleDbCommand("SELECT
OTHWAGE.* FROM OTHWAGE", myConnection)
myConnection.Open()
Dim myReader As System.Data.OleDb.OleDbDataReader =
myCommand.ExecuteReader()
While myReader.Read()
Debug.WriteLine(CStr(myReader.GetValue(0)))
End While
"Cindy Winegarden" wrote:
Hi Joe,

First off, try the FoxPro and Visual FoxPro OLE DB data provider,
available

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: PM | last post by:
Has anyone found a way to open a file exclusively where it will fail if the file is already open, i have tried the following _FileStream = new FileStream(@"C:\Data.txt", FileMode.Open,...
1
by: Alfons | last post by:
Hello, I have build a program that can do file transferring between a Windows XP computer and a DOS computer via a serial port. The Windows program I have build in C++ with Visual Studio 6.0....
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
0
by: John Winterbottom | last post by:
Does anyone know if this is possible? We are running Access XP with Windows XP Prof.. We have an ADP file we are using to print custom reports for a client. It's opened and conntrolled through...
5
by: Brad | last post by:
In several aspx applications I export crytal reports to pdf, xls and doc files and then the aspx page writes the selected export file to the client browser. This all works with one small quirk: ...
11
by: aldrin | last post by:
I'm trying to run this code under windows xp sp2 using codeblocks v1.0 compiler with great difficulty.There is no problem with running this under KDevelop in linux. Any help would be greatly...
1
by: gangs | last post by:
I need to know how can I open a file which is named using UTF-16 encoding in unicode. I am desperately trying to open the file using the wofstream typedef, but even it takes the parameter as const...
9
compman9902
by: compman9902 | last post by:
Hello, and thank toy for reading this post. Thus far, this website has helped me a lot, (I have finally finished my encryptor: "site removed by moderator", go to the downloads link) and I will...
15
by: Umesh | last post by:
how to open a website like yahoo.com and use it as input? The following code doesn't work. #include"stdio.h" int main() { FILE *f; f=fopen("http://www.yahoo.com","r"); if(f==NULL)
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.